#--
# Copyright (c) 2007 Maximilian Ott
# 
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# 
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#++
#
# Create a table holding information on users.
#
#
class CreateUsers < ActiveRecord::Migration
  
  def self.up
    create_table "users", :force => true do |t|
      t.column "login",        :string,    :limit => 40,  :default => "",    :null => false
      t.column "name",         :string,    :limit => 128, :default => "",    :null => false
      t.column "admin",        :integer,   :limit => 1,   :default => 0,     :null => false
      t.column "activated",    :integer,   :limit => 1,   :default => 0,     :null => false
      t.column "email",        :string,    :limit => 80,  :default => "",    :null => false
      t.column "cypher",       :text,                     :default => "",    :null => false
      t.column "salt",         :string,    :limit => 40,  :default => "",    :null => false
      t.column "token",        :string,    :limit => 10,  :default => "",    :null => false
      t.column "token_expiry", :timestamp
      t.column "lock_version", :integer,                  :default => 0,     :null => false
      t.column "is_approver",  :boolean
      t.column "ldap_dn",      :string
      t.column "is_local",     :boolean,                  :default => false
      t.column "created_on",   :timestamp
      t.column "updated_on",   :timestamp
    end
    add_index "users", ["login"], :name => "login"
    add_index "users", ["email"], :name => "email"
  end

  def self.down
    drop_table :users
  end
end
